package lu.uni.adtool;

import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import lu.uni.adtool.ui.MainWindow;
import net.infonode.docking.RootWindow;

/**
 * The Class Main of ADTool application.
 *
 * @author Piotr Kordy
 * @version 0.1
 */
public final class Main
{

  private static final int ICON_SIZE = 8;
  private static final int MIN_JAVA_NUM = 6;

  private RootWindow rootWindow;

  /**
   * Hidden private constructor
   */
  private Main()
  {
  }

  /**
   * The main method.
   *
   * @param args the arguments
   */
  public static void main(final String[] args)
  {
    final String vendor = System.getProperty("java.vendor");
    final String version = System.getProperty("java.version");
    boolean correctversion = false;
    final String[] versnbr = version.split("\\.");
    if (versnbr.length > 2) {
      final int vers = Integer.valueOf(versnbr[1]).intValue();
      if (vers >= MIN_JAVA_NUM) {
        correctversion = true;
      }
    }
    if (!correctversion) {
      // JOptionPane.showMessageDialog(null,
      System.out.println("The system has: " + vendor + " " + version + "\n" + "You should at least have: 1.6.0_26 " +
          "from Sun Microsytems Inc.\n" + "Not all features will be supported.");
      // JOptionPane.WARNING_MESSAGE);
      // System.exit(1);
    }
    try {
      // Set System Default Look and Feel
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (UnsupportedLookAndFeelException e) {
      System.err.println("Could not set up a default system Look and " + "Feel:" + e.getLocalizedMessage());
    } catch (ClassNotFoundException e) {
      System.err.println("Could not set up a default system Look and " + "Feel:" + e.getLocalizedMessage());
    } catch (InstantiationException e) {
      System.err.println("Could not set up a default system Look and " + "Feel:" + e.getLocalizedMessage());
    } catch (IllegalAccessException e) {
      System.err.println("Could not set up a default system Look and " + "Feel:" + e.getLocalizedMessage());
    }

    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        new MainWindow();
      }
    });
  }
}
